import { useEffect, useRef } from 'react'
import {useVisionRootStore} from './LayoutData'
import { useForceUpdate } from '@/pages/index'

function getComponent({item}) {
    let dom = useRef(null)
    let {allComponent} = useVisionRootStore()
    let code = item.code
    let Component = allComponent[code].render
  const update = useForceUpdate()

    useEffect(()=>{
      item.setDom(dom)
      item.forceUpdate = update
      console.log(item, '?????????')
    }, [])
    return <div data-my='node' ref={dom}>
        <Component opNode={item}/>
      </div>
}

export default getComponent